package com.zhuss.controller.excecise;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zhuss.bean.bo.excecise.excecise.CreateExceciseBo;
import com.zhuss.bean.bo.excecise.excecise.DeleteExceciseBo;
import com.zhuss.bean.bo.excecise.excecise.UpdateExceciseBo;
import com.zhuss.bean.bo.excecise.excecise.wechat.CollectExceciseBo;
import com.zhuss.bean.bo.excecise.excecise.wechat.DelTopicExceciseBo;
import com.zhuss.bean.bo.excecise.excecise.wechat.ForwardExceciseBo;
import com.zhuss.bean.bo.excecise.excecise.wechat.RecommendExceciseBo;
import com.zhuss.bean.bo.excecise.excecise.wechat.ThumbExceciseBo;
import com.zhuss.bean.bo.excecise.excecise.wechat.TopicExceciseBo;
import com.zhuss.bean.bo.opus.invit.CreateInvitBo;
import com.zhuss.bean.bo.opus.invit.DeleteInvitBo;
import com.zhuss.bean.bo.opus.invit.UpdateInvitBo;
import com.zhuss.bean.bo.opus.invit.wechat.CollectInvitBo;
import com.zhuss.bean.bo.opus.invit.wechat.DelTopicInvitBo;
import com.zhuss.bean.bo.opus.invit.wechat.ForwardInvitBo;
import com.zhuss.bean.bo.opus.invit.wechat.RecommendInvitBo;
import com.zhuss.bean.bo.opus.invit.wechat.ThumbInvitBo;
import com.zhuss.bean.bo.opus.invit.wechat.TopicInvitBo;
import com.zhuss.common.BaseController;
import com.zhuss.common.OperateService;
import com.zhuss.enums.BannerType;
import com.zhuss.exception.WpsException;
import com.zhuss.opus.invit.InvitOperateServiceExt;


/**
 * excecise操作 controller
 * @Author zhushanshuo
   @Date 2020-02-04 22:58
 *
 */
  
 
@RestController
@RequestMapping("/excecise")
public class ExceciseOperateController extends BaseController {
	
	/*@Autowired
	@Qualifier("invitOperateService")
	private OperateService<Void, Object> invitOperateService;
	
	@Autowired
	@Qualifier("invitOperateServiceExt")
	private ExceciseOperateServiceExt invitOperateServiceExt;*/
	
	@Autowired
	@Qualifier("invitOperateService")
	private OperateService<Void, Object> invitOperateService;
	
	@Autowired
	@Qualifier("invitOperateServiceExt")
	private InvitOperateServiceExt invitOperateServiceExt;
	
	/**
	 * 创建
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
    @PostMapping("/create")
    public void create(@RequestBody CreateExceciseBo bo) throws WpsException {
		CreateInvitBo param = new CreateInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitType(BannerType.练习生.key());
		invitOperateService.create(param);
    }
	
	
	/**
	 * 修改
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
    @PostMapping("/update")
    public void update(@RequestBody UpdateExceciseBo bo) throws WpsException {
		UpdateInvitBo param = new UpdateInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getExceciseId());
		invitOperateService.update(param);
    }
	
	/**
	 * 删除
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
    @PostMapping("/delete")
    public void delete(@RequestBody DeleteExceciseBo bo) throws WpsException {
		DeleteInvitBo param = new DeleteInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getExceciseId());
		invitOperateService.delete(param);
    }
	
	/**
	 * 点赞
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/thumb")
	public void thumb(@RequestBody ThumbExceciseBo bo) throws WpsException {
		ThumbInvitBo param = new ThumbInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getExceciseId());
		invitOperateServiceExt.thumb(param);
	}
	
	
	/**
	 * 收藏
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/collect")
	public void collect(@RequestBody CollectExceciseBo bo) throws WpsException {
		CollectInvitBo param = new CollectInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getExceciseId());
		invitOperateServiceExt.collect(param);
	}
	
	/**
	 * 转发
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/forward")
	public void forward(@RequestBody ForwardExceciseBo bo) throws WpsException {
		ForwardInvitBo param = new ForwardInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getExceciseId());
		invitOperateServiceExt.forward(param);
	}
	
	/**
	 * 推荐
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/recommend")
	public void recommend(@RequestBody RecommendExceciseBo bo) throws WpsException {
		RecommendInvitBo param = new RecommendInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getExceciseId());
		invitOperateServiceExt.recommend(param);
	}
	
	/**
	 * 取消
	 * 点赞
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/delThumb")
	public void delThumb(@RequestBody ThumbExceciseBo bo) throws WpsException {
		ThumbInvitBo param = new ThumbInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getExceciseId());
		invitOperateServiceExt.delThumb(param);
	}
	
	
	/**
	 * 取消
	 * 收藏
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/delCollect")
	public void delCollect(@RequestBody CollectExceciseBo bo) throws WpsException {
		CollectInvitBo param = new CollectInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getExceciseId());
		invitOperateServiceExt.delCollect(param);
	}
	
	/**
	 * 取消
	 * 转发
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/delForward")
	public void delForward(@RequestBody ForwardExceciseBo bo) throws WpsException {
		ForwardInvitBo param = new ForwardInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getExceciseId());
		invitOperateServiceExt.delForward(param);
	}
	
	/**
	 * 取消
	 * 推荐
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/delRecommend")
	public void delRecommend(@RequestBody RecommendExceciseBo bo) throws WpsException {
		RecommendInvitBo param = new RecommendInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getExceciseId());
		invitOperateServiceExt.delRecommend(param);
	}
	
	
	/**
	 * 评论
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/topic")
	public void topic(@RequestBody TopicExceciseBo bo) throws WpsException {
		TopicInvitBo param = new TopicInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getExceciseId());
		invitOperateServiceExt.topic(param);
	}
	
	/**
	 * 删
	 * 评论
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/delTopic")
	public void delTopic(@RequestBody DelTopicExceciseBo bo) throws WpsException {
		DelTopicInvitBo param = new DelTopicInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitTopicId(bo.getExceciseTopicId());
		param.setInvitTopicIdList(bo.getExceciseTopicIdList());
		invitOperateServiceExt.delTopic(param);
	}
	
}
